const mapApi = require("../utils/requestmap")

const { router } = require("../koa")
router.get("/position", async (ctx) => {
    try {
        let { key } = ctx.query
        let result = await mapApi.reqPosition(key)
        ctx.body = result
    } catch (error) {
        console.log(error);
        ctx.body = error
    }
})
router.post("/district", async (ctx) => {
    try {
        let districtData = ctx.request.body
        let result = await mapApi.reqDistrict(districtData)
        ctx.body = result
    } catch (error) {
        ctx.body = error
    }
})
// 根据坐标获取位置信息
router.post('/regeo', async (ctx) => {
    try {
        let locationData = ctx.request.body
        let result = await mapApi.getRegeo(locationData)
        ctx.body = result
    } catch (error) {
        ctx.body = error
    }

})
router.post("/search",async(ctx)=>{
    let HintData = ctx.request.body
    let result = await mapApi.searchHint(HintData)
    ctx.body=result
})